package com.opengroupe.dao.impl;

// Generated 31 juil. 2012 15:44:44 by Hibernate Tools 3.4.0.CR1

import java.util.List;

import javax.ejb.Stateless;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.jpa.support.JpaDaoSupport;

import com.opengroupe.dao.ReponseDao;
import com.opengroupe.entities.Reponse;

/**
 * Home object for domain model class Reponse.
 * 
 * @see com.opengroupe.entities.Reponse
 * @author Hibernate Tools
 */
@Stateless
public class ReponseDaoImpl extends JpaDaoSupport implements ReponseDao {

	private static final Log log = LogFactory.getLog(ReponseDaoImpl.class);

	public Reponse persist(Reponse transientInstance) {
		log.debug("persisting Reponse instance");
		try {
			getJpaTemplate().persist(transientInstance);
			log.debug("persist successful");
			return transientInstance;
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void remove(Reponse persistentInstance) {
		log.debug("removing Reponse instance");
		try {
			getJpaTemplate().remove(persistentInstance);
			log.debug("remove successful");
		} catch (RuntimeException re) {
			log.error("remove failed", re);
			throw re;
		}
	}

	public Reponse merge(Reponse detachedInstance) {
		log.debug("merging Reponse instance");
		try {
			Reponse result = getJpaTemplate().merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}

	public Reponse findById(Integer id) {
		log.debug("getting Reponse instance with id: " + id);
		try {
			Reponse instance = getJpaTemplate().find(Reponse.class, id);
			log.debug("get successful");
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Reponse> findAll() {
		log.debug("getting all Reponse instances");
		try {
			List<Reponse> reponses = (List<Reponse>)getJpaTemplate().find("from Reponse");
			log.debug("findAll successful");
			return reponses;

		} catch (RuntimeException re) {
			log.error("findAll failed", re);
			throw re;
		}
	}
}
